<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link href="cpip.css" rel="stylesheet" type="text/css" />
    <title>File: /Users/paulross/dev/linux/linux-3.13/include/linux/key.h</title>
  </head>
  <body>
    <h1>File: /Users/paulross/dev/linux/linux-3.13/include/linux/key.h</h1>
    <p>Green shading in the line number column
means the source is part of the translation unit, red means it is conditionally excluded.
Highlighted line numbers link to the translation unit page. Highlighted macros link to
the macro page.</p>
    <pre><a name="1" /><span class="True">       1:</span> <span class="k">/* Authentication token and access key management</span>
<a name="2" /><span class="True">       2:</span> <span class="k"> *</span>
<a name="3" /><span class="True">       3:</span> <span class="k"> * Copyright (C) 2004, 2007 Red Hat, Inc. All Rights Reserved.</span>
<a name="4" /><span class="True">       4:</span> <span class="k"> * Written by David Howells (dhowells@redhat.com)</span>
<a name="5" /><span class="True">       5:</span> <span class="k"> *</span>
<a name="6" /><span class="True">       6:</span> <span class="k"> * This program is free software; you can redistribute it and/or</span>
<a name="7" /><span class="True">       7:</span> <span class="k"> * modify it under the terms of the GNU General Public License</span>
<a name="8" /><span class="True">       8:</span> <span class="k"> * as published by the Free Software Foundation; either version</span>
<a name="9" /><span class="True">       9:</span> <span class="k"> * 2 of the License, or (at your option) any later version.</span>
<a name="10" /><span class="True">      10:</span> <span class="k"> *</span>
<a name="11" /><span class="True">      11:</span> <span class="k"> *</span>
<a name="12" /><span class="True">      12:</span> <span class="k"> * See Documentation/security/keys.txt for information on keys/keyrings.</span>
<a name="13" /><span class="True">      13:</span> <span class="k"> */</span>
<a name="14" /><span class="True">      14:</span> 
<a name="15" /><span class="True">      15:</span> <span class="f">#</span><span class="n">ifndef</span> <a href="cpu.c_macros_noref.html#_X0xJTlVYX0tFWV9IXzA_"><span class="b">_LINUX_KEY_H</span></a>
<a name="16" /><span class="True">      16:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_X0xJTlVYX0tFWV9IXzA_"><span class="b">_LINUX_KEY_H</span></a>
<a name="17" /><span class="True">      17:</span> 
<a name="18" /><span class="True">      18:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">types</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="19" /><span class="True">      19:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">list</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="20" /><span class="True">      20:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">rbtree</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="21" /><span class="True">      21:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">rcupdate</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="22" /><span class="True">      22:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">sysctl</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="23" /><span class="True">      23:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">rwsem</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="24" /><span class="True">      24:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">atomic</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="25" /><span class="True">      25:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">assoc_array</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="26" /><span class="True">      26:</span> 
<a name="27" /><span class="True">      27:</span> <span class="f">#</span><span class="n">ifdef</span> <a href="cpu.c_macros_ref.html#_X19LRVJORUxfX18w"><span class="b">__KERNEL__</span></a>
<a name="28" /><span class="True">      28:</span> <span class="f">#</span><span class="n">include</span> <span class="f">&lt;</span><span class="b">linux</span><span class="f">/</span><span class="b">uidgid</span><span class="f">.</span><span class="b">h</span><span class="f">&gt;</span>
<a name="29" /><span class="True">      29:</span> 
<a name="30" /><span class="True">      30:</span> <span class="k">/* key handle serial number */</span>
<a name="31" /><span class="True">      31:</span> <span class="m">typedef</span> <span class="b">int32_t</span> <span class="b">key_serial_t</span><span class="f">;</span>
<a name="32" /><span class="True">      32:</span> 
<a name="33" /><span class="True">      33:</span> <span class="k">/* key handle permissions mask */</span>
<a name="34" /><span class="True">      34:</span> <span class="m">typedef</span> <span class="b">uint32_t</span> <span class="b">key_perm_t</span><span class="f">;</span>
<a name="35" /><span class="True">      35:</span> 
<a name="36" /><span class="True">      36:</span> <span class="m">struct</span> <span class="b">key</span><span class="f">;</span>
<a name="37" /><span class="True">      37:</span> 
<a name="38" /><span class="True">      38:</span> <span class="f">#</span><span class="n">ifdef</span> <a href="cpu.c_macros_ref.html#_Q09ORklHX0tFWVNfMA__"><span class="b">CONFIG_KEYS</span></a>
<a name="39" /><span class="True">      39:</span> 
<a name="40" /><span class="True">      40:</span> <span class="f">#</span><span class="n">undef</span> <span class="b">KEY_DEBUGGING</span>
<a name="41" /><span class="True">      41:</span> 
<a name="42" /><span class="True">      42:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19WSUVXXzA_"><span class="b">KEY_POS_VIEW</span></a>    <span class="c">0x01000000</span>    <span class="k">/* possessor can view a key&apos;s attributes */</span>
<a name="43" /><span class="True">      43:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19SRUFEXzA_"><span class="b">KEY_POS_READ</span></a>    <span class="c">0x02000000</span>    <span class="k">/* possessor can read key payload / view keyring */</span>
<a name="44" /><span class="True">      44:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19XUklURV8w"><span class="b">KEY_POS_WRITE</span></a>    <span class="c">0x04000000</span>    <span class="k">/* possessor can update key payload / add link to keyring */</span>
<a name="45" /><span class="True">      45:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19TRUFSQ0hfMA__"><span class="b">KEY_POS_SEARCH</span></a>    <span class="c">0x08000000</span>    <span class="k">/* possessor can find a key in search / search a keyring */</span>
<a name="46" /><span class="True">      46:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19MSU5LXzA_"><span class="b">KEY_POS_LINK</span></a>    <span class="c">0x10000000</span>    <span class="k">/* possessor can create a link to a key/keyring */</span>
<a name="47" /><span class="True">      47:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19TRVRBVFRSXzA_"><span class="b">KEY_POS_SETATTR</span></a>    <span class="c">0x20000000</span>    <span class="k">/* possessor can set key attributes */</span>
<a name="48" /><span class="True">      48:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BPU19BTExfMA__"><span class="b">KEY_POS_ALL</span></a>    <span class="c">0x3f000000</span>
<a name="49" /><span class="True">      49:</span> 
<a name="50" /><span class="True">      50:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9WSUVXXzA_"><span class="b">KEY_USR_VIEW</span></a>    <span class="c">0x00010000</span>    <span class="k">/* user permissions... */</span>
<a name="51" /><span class="True">      51:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9SRUFEXzA_"><span class="b">KEY_USR_READ</span></a>    <span class="c">0x00020000</span>
<a name="52" /><span class="True">      52:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9XUklURV8w"><span class="b">KEY_USR_WRITE</span></a>    <span class="c">0x00040000</span>
<a name="53" /><span class="True">      53:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9TRUFSQ0hfMA__"><span class="b">KEY_USR_SEARCH</span></a>    <span class="c">0x00080000</span>
<a name="54" /><span class="True">      54:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9MSU5LXzA_"><span class="b">KEY_USR_LINK</span></a>    <span class="c">0x00100000</span>
<a name="55" /><span class="True">      55:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9TRVRBVFRSXzA_"><span class="b">KEY_USR_SETATTR</span></a>    <span class="c">0x00200000</span>
<a name="56" /><span class="True">      56:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1VTUl9BTExfMA__"><span class="b">KEY_USR_ALL</span></a>    <span class="c">0x003f0000</span>
<a name="57" /><span class="True">      57:</span> 
<a name="58" /><span class="True">      58:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9WSUVXXzA_"><span class="b">KEY_GRP_VIEW</span></a>    <span class="c">0x00000100</span>    <span class="k">/* group permissions... */</span>
<a name="59" /><span class="True">      59:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9SRUFEXzA_"><span class="b">KEY_GRP_READ</span></a>    <span class="c">0x00000200</span>
<a name="60" /><span class="True">      60:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9XUklURV8w"><span class="b">KEY_GRP_WRITE</span></a>    <span class="c">0x00000400</span>
<a name="61" /><span class="True">      61:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9TRUFSQ0hfMA__"><span class="b">KEY_GRP_SEARCH</span></a>    <span class="c">0x00000800</span>
<a name="62" /><span class="True">      62:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9MSU5LXzA_"><span class="b">KEY_GRP_LINK</span></a>    <span class="c">0x00001000</span>
<a name="63" /><span class="True">      63:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9TRVRBVFRSXzA_"><span class="b">KEY_GRP_SETATTR</span></a>    <span class="c">0x00002000</span>
<a name="64" /><span class="True">      64:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0dSUF9BTExfMA__"><span class="b">KEY_GRP_ALL</span></a>    <span class="c">0x00003f00</span>
<a name="65" /><span class="True">      65:</span> 
<a name="66" /><span class="True">      66:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9WSUVXXzA_"><span class="b">KEY_OTH_VIEW</span></a>    <span class="c">0x00000001</span>    <span class="k">/* third party permissions... */</span>
<a name="67" /><span class="True">      67:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9SRUFEXzA_"><span class="b">KEY_OTH_READ</span></a>    <span class="c">0x00000002</span>
<a name="68" /><span class="True">      68:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9XUklURV8w"><span class="b">KEY_OTH_WRITE</span></a>    <span class="c">0x00000004</span>
<a name="69" /><span class="True">      69:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9TRUFSQ0hfMA__"><span class="b">KEY_OTH_SEARCH</span></a>    <span class="c">0x00000008</span>
<a name="70" /><span class="True">      70:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9MSU5LXzA_"><span class="b">KEY_OTH_LINK</span></a>    <span class="c">0x00000010</span>
<a name="71" /><span class="True">      71:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9TRVRBVFRSXzA_"><span class="b">KEY_OTH_SETATTR</span></a>    <span class="c">0x00000020</span>
<a name="72" /><span class="True">      72:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX09USF9BTExfMA__"><span class="b">KEY_OTH_ALL</span></a>    <span class="c">0x0000003f</span>
<a name="73" /><span class="True">      73:</span> 
<a name="74" /><span class="True">      74:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX1BFUk1fVU5ERUZfMA__"><span class="b">KEY_PERM_UNDEF</span></a>    <span class="c">0xffffffff</span>
<a name="75" /><span class="True">      75:</span> 
<a name="76" /><span class="True">      76:</span> <span class="m">struct</span> <span class="b">seq_file</span><span class="f">;</span>
<a name="77" /><span class="True">      77:</span> <span class="m">struct</span> <span class="b">user_struct</span><span class="f">;</span>
<a name="78" /><span class="True">      78:</span> <span class="m">struct</span> <span class="b">signal_struct</span><span class="f">;</span>
<a name="79" /><span class="True">      79:</span> <span class="m">struct</span> <span class="b">cred</span><span class="f">;</span>
<a name="80" /><span class="True">      80:</span> 
<a name="81" /><span class="True">      81:</span> <span class="m">struct</span> <span class="b">key_type</span><span class="f">;</span>
<a name="82" /><span class="True">      82:</span> <span class="m">struct</span> <span class="b">key_owner</span><span class="f">;</span>
<a name="83" /><span class="True">      83:</span> <span class="m">struct</span> <span class="b">keyring_list</span><span class="f">;</span>
<a name="84" /><span class="True">      84:</span> <span class="m">struct</span> <span class="b">keyring_name</span><span class="f">;</span>
<a name="85" /><span class="True">      85:</span> 
<a name="86" /><span class="True">      86:</span> <span class="m">struct</span> <span class="b">keyring_index_key</span> <span class="f">{</span>
<a name="87" /><span class="True">      87:</span>     <span class="m">struct</span> <span class="b">key_type</span>        <span class="f">*</span><span class="b">type</span><span class="f">;</span>
<a name="88" /><span class="True">      88:</span>     <span class="m">const</span> <span class="m">char</span>        <span class="f">*</span><span class="b">description</span><span class="f">;</span>
<a name="89" /><span class="True">      89:</span>     <span class="b">size_t</span>            <span class="b">desc_len</span><span class="f">;</span>
<a name="90" /><span class="True">      90:</span> <span class="f">}</span><span class="f">;</span>
<a name="91" /><span class="True">      91:</span> 
<a name="92" /><span class="True">      92:</span> <span class="k">/*****************************************************************************/</span>
<a name="93" /><span class="True">      93:</span> <span class="k">/*</span>
<a name="94" /><span class="True">      94:</span> <span class="k"> * key reference with possession attribute handling</span>
<a name="95" /><span class="True">      95:</span> <span class="k"> *</span>
<a name="96" /><span class="True">      96:</span> <span class="k"> * NOTE! key_ref_t is a typedef&apos;d pointer to a type that is not actually</span>
<a name="97" /><span class="True">      97:</span> <span class="k"> * defined. This is because we abuse the bottom bit of the reference to carry a</span>
<a name="98" /><span class="True">      98:</span> <span class="k"> * flag to indicate whether the calling process possesses that key in one of</span>
<a name="99" /><span class="True">      99:</span> <span class="k"> * its keyrings.</span>
<a name="100" /><span class="True">     100:</span> <span class="k"> *</span>
<a name="101" /><span class="True">     101:</span> <span class="k"> * the key_ref_t has been made a separate type so that the compiler can reject</span>
<a name="102" /><span class="True">     102:</span> <span class="k"> * attempts to dereference it without proper conversion.</span>
<a name="103" /><span class="True">     103:</span> <span class="k"> *</span>
<a name="104" /><span class="True">     104:</span> <span class="k"> * the three functions are used to assemble and disassemble references</span>
<a name="105" /><span class="True">     105:</span> <span class="k"> */</span>
<a name="106" /><span class="True">     106:</span> <span class="m">typedef</span> <span class="m">struct</span> <span class="b">__key_reference_with_attributes</span> <span class="f">*</span><span class="b">key_ref_t</span><span class="f">;</span>
<a name="107" /><span class="True">     107:</span> 
<a name="108" /><span class="True">     108:</span> <span class="m">static</span> <span class="m">inline</span> <span class="b">key_ref_t</span> <span class="b">make_key_ref</span><span class="f">(</span><span class="m">const</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">,</span>
<a name="109" /><span class="True">     109:</span>                      <span class="m">bool</span> <span class="b">possession</span><span class="f">)</span>
<a name="110" /><span class="True">     110:</span> <span class="f">{</span>
<a name="111" /><span class="True">     111:</span>     <span class="m">return</span> <span class="f">(</span><span class="b">key_ref_t</span><span class="f">)</span> <span class="f">(</span><span class="f">(</span><span class="m">unsigned</span> <span class="m">long</span><span class="f">)</span> <span class="b">key</span> <span class="f">|</span> <span class="b">possession</span><span class="f">)</span><span class="f">;</span>
<a name="112" /><span class="True">     112:</span> <span class="f">}</span>
<a name="113" /><span class="True">     113:</span> 
<a name="114" /><span class="True">     114:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key_ref_to_ptr</span><span class="f">(</span><span class="m">const</span> <span class="b">key_ref_t</span> <span class="b">key_ref</span><span class="f">)</span>
<a name="115" /><span class="True">     115:</span> <span class="f">{</span>
<a name="116" /><span class="True">     116:</span>     <span class="m">return</span> <span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="f">)</span> <span class="f">(</span><span class="f">(</span><span class="m">unsigned</span> <span class="m">long</span><span class="f">)</span> <span class="b">key_ref</span> <span class="f">&amp;</span> <span class="f">~</span><span class="c">1UL</span><span class="f">)</span><span class="f">;</span>
<a name="117" /><span class="True">     117:</span> <span class="f">}</span>
<a name="118" /><span class="True">     118:</span> 
<a name="119" /><span class="True">     119:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">bool</span> <span class="b">is_key_possessed</span><span class="f">(</span><span class="m">const</span> <span class="b">key_ref_t</span> <span class="b">key_ref</span><span class="f">)</span>
<a name="120" /><span class="True">     120:</span> <span class="f">{</span>
<a name="121" /><span class="True">     121:</span>     <span class="m">return</span> <span class="f">(</span><span class="m">unsigned</span> <span class="m">long</span><span class="f">)</span> <span class="b">key_ref</span> <span class="f">&amp;</span> <span class="c">1UL</span><span class="f">;</span>
<a name="122" /><span class="True">     122:</span> <span class="f">}</span>
<a name="123" /><span class="True">     123:</span> 
<a name="124" /><span class="True">     124:</span> <span class="k">/*****************************************************************************/</span>
<a name="125" /><span class="True">     125:</span> <span class="k">/*</span>
<a name="126" /><span class="True">     126:</span> <span class="k"> * authentication token / access credential / keyring</span>
<a name="127" /><span class="True">     127:</span> <span class="k"> * - types of key include:</span>
<a name="128" /><span class="True">     128:</span> <span class="k"> *   - keyrings</span>
<a name="129" /><span class="True">     129:</span> <span class="k"> *   - disk encryption IDs</span>
<a name="130" /><span class="True">     130:</span> <span class="k"> *   - Kerberos TGTs and tickets</span>
<a name="131" /><span class="True">     131:</span> <span class="k"> */</span>
<a name="132" /><span class="True">     132:</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">{</span>
<a name="133" /><span class="True">     133:</span>     <span class="b">atomic_t</span>        <span class="b">usage</span><span class="f">;</span>        <span class="k">/* number of references */</span>
<a name="134" /><span class="True">     134:</span>     <span class="b">key_serial_t</span>        <span class="b">serial</span><span class="f">;</span>        <span class="k">/* key serial number */</span>
<a name="135" /><span class="True">     135:</span>     <span class="m">union</span> <span class="f">{</span>
<a name="136" /><span class="True">     136:</span>         <span class="m">struct</span> <span class="b">list_head</span> <span class="b">graveyard_link</span><span class="f">;</span>
<a name="137" /><span class="True">     137:</span>         <span class="m">struct</span> <span class="b">rb_node</span>    <span class="b">serial_node</span><span class="f">;</span>
<a name="138" /><span class="True">     138:</span>     <span class="f">}</span><span class="f">;</span>
<a name="139" /><span class="True">     139:</span>     <span class="m">struct</span> <span class="b">rw_semaphore</span>    <span class="b">sem</span><span class="f">;</span>        <span class="k">/* change vs change sem */</span>
<a name="140" /><span class="True">     140:</span>     <span class="m">struct</span> <span class="b">key_user</span>        <span class="f">*</span><span class="b">user</span><span class="f">;</span>        <span class="k">/* owner of this key */</span>
<a name="141" /><span class="True">     141:</span>     <span class="m">void</span>            <span class="f">*</span><span class="b">security</span><span class="f">;</span>    <span class="k">/* security data for this key */</span>
<a name="142" /><span class="True">     142:</span>     <span class="m">union</span> <span class="f">{</span>
<a name="143" /><span class="True">     143:</span>         <span class="b">time_t</span>        <span class="b">expiry</span><span class="f">;</span>        <span class="k">/* time at which key expires (or 0) */</span>
<a name="144" /><span class="True">     144:</span>         <span class="b">time_t</span>        <span class="b">revoked_at</span><span class="f">;</span>    <span class="k">/* time at which key was revoked */</span>
<a name="145" /><span class="True">     145:</span>     <span class="f">}</span><span class="f">;</span>
<a name="146" /><span class="True">     146:</span>     <span class="b">time_t</span>            <span class="b">last_used_at</span><span class="f">;</span>    <span class="k">/* last time used for LRU keyring discard */</span>
<a name="147" /><span class="True">     147:</span>     <span class="b">kuid_t</span>            <span class="b">uid</span><span class="f">;</span>
<a name="148" /><span class="True">     148:</span>     <span class="b">kgid_t</span>            <span class="b">gid</span><span class="f">;</span>
<a name="149" /><span class="True">     149:</span>     <span class="b">key_perm_t</span>        <span class="b">perm</span><span class="f">;</span>        <span class="k">/* access permissions */</span>
<a name="150" /><span class="True">     150:</span>     <span class="m">unsigned</span> <span class="m">short</span>        <span class="b">quotalen</span><span class="f">;</span>    <span class="k">/* length added to quota */</span>
<a name="151" /><span class="True">     151:</span>     <span class="m">unsigned</span> <span class="m">short</span>        <span class="b">datalen</span><span class="f">;</span>    <span class="k">/* payload data length</span>
<a name="152" /><span class="True">     152:</span> <span class="k">                         * - may not match RCU dereferenced payload</span>
<a name="153" /><span class="True">     153:</span> <span class="k">                         * - payload should contain own length</span>
<a name="154" /><span class="True">     154:</span> <span class="k">                         */</span>
<a name="155" /><span class="True">     155:</span> 
<a name="156" /><span class="False">     156:</span> <span class="f">#</span><span class="n">ifdef</span> <span class="b">KEY_DEBUGGING</span>
<a name="157" /><span class="False">     157:</span>     <span class="m">unsigned</span>        <span class="b">magic</span><span class="f">;</span>
<a name="158" /><span class="False">     158:</span> <span class="f">#</span><span class="n">define</span> <span class="b">KEY_DEBUG_MAGIC</span>        <span class="c">0x18273645u</span>
<a name="159" /><span class="False">     159:</span> <span class="f">#</span><span class="n">define</span> <span class="b">KEY_DEBUG_MAGIC_X</span>    <span class="c">0xf8e9dacbu</span>
<a name="160" /><span class="True">     160:</span> <span class="f">#</span><span class="n">endif</span>
<a name="161" /><span class="True">     161:</span> 
<a name="162" /><span class="True">     162:</span>     <span class="m">unsigned</span> <span class="m">long</span>        <span class="b">flags</span><span class="f">;</span>        <span class="k">/* status flags (change with bitops) */</span>
<a name="163" /><span class="True">     163:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_ref.html#_S0VZX0ZMQUdfSU5TVEFOVElBVEVEXzA_"><span class="b">KEY_FLAG_INSTANTIATED</span></a>    <span class="c">0</span>    <span class="k">/* set if key has been instantiated */</span>
<a name="164" /><span class="True">     164:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfREVBRF8w"><span class="b">KEY_FLAG_DEAD</span></a>        <span class="c">1</span>    <span class="k">/* set if key type has been deleted */</span>
<a name="165" /><span class="True">     165:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfUkVWT0tFRF8w"><span class="b">KEY_FLAG_REVOKED</span></a>    <span class="c">2</span>    <span class="k">/* set if key had been revoked */</span>
<a name="166" /><span class="True">     166:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfSU5fUVVPVEFfMA__"><span class="b">KEY_FLAG_IN_QUOTA</span></a>    <span class="c">3</span>    <span class="k">/* set if key consumes quota */</span>
<a name="167" /><span class="True">     167:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfVVNFUl9DT05TVFJVQ1RfMA__"><span class="b">KEY_FLAG_USER_CONSTRUCT</span></a>    <span class="c">4</span>    <span class="k">/* set if key is being constructed in userspace */</span>
<a name="168" /><span class="True">     168:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_ref.html#_S0VZX0ZMQUdfTkVHQVRJVkVfMA__"><span class="b">KEY_FLAG_NEGATIVE</span></a>    <span class="c">5</span>    <span class="k">/* set if key is negative */</span>
<a name="169" /><span class="True">     169:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfUk9PVF9DQU5fQ0xFQVJfMA__"><span class="b">KEY_FLAG_ROOT_CAN_CLEAR</span></a>    <span class="c">6</span>    <span class="k">/* set if key can be cleared by root without permission */</span>
<a name="170" /><span class="True">     170:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfSU5WQUxJREFURURfMA__"><span class="b">KEY_FLAG_INVALIDATED</span></a>    <span class="c">7</span>    <span class="k">/* set if key has been invalidated */</span>
<a name="171" /><span class="True">     171:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfVFJVU1RFRF8w"><span class="b">KEY_FLAG_TRUSTED</span></a>    <span class="c">8</span>    <span class="k">/* set if key is trusted */</span>
<a name="172" /><span class="True">     172:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0ZMQUdfVFJVU1RFRF9PTkxZXzA_"><span class="b">KEY_FLAG_TRUSTED_ONLY</span></a>    <span class="c">9</span>    <span class="k">/* set if keyring only accepts links to trusted keys */</span>
<a name="173" /><span class="True">     173:</span> 
<a name="174" /><span class="True">     174:</span>     <span class="k">/* the key type and key description string</span>
<a name="175" /><span class="True">     175:</span> <span class="k">     * - the desc is used to match a key against search criteria</span>
<a name="176" /><span class="True">     176:</span> <span class="k">     * - it should be a printable string</span>
<a name="177" /><span class="True">     177:</span> <span class="k">     * - eg: for krb5 AFS, this might be &quot;afs@REDHAT.COM&quot;</span>
<a name="178" /><span class="True">     178:</span> <span class="k">     */</span>
<a name="179" /><span class="True">     179:</span>     <span class="m">union</span> <span class="f">{</span>
<a name="180" /><span class="True">     180:</span>         <span class="m">struct</span> <span class="b">keyring_index_key</span> <span class="b">index_key</span><span class="f">;</span>
<a name="181" /><span class="True">     181:</span>         <span class="m">struct</span> <span class="f">{</span>
<a name="182" /><span class="True">     182:</span>             <span class="m">struct</span> <span class="b">key_type</span>    <span class="f">*</span><span class="b">type</span><span class="f">;</span>        <span class="k">/* type of key */</span>
<a name="183" /><span class="True">     183:</span>             <span class="m">char</span>        <span class="f">*</span><span class="b">description</span><span class="f">;</span>
<a name="184" /><span class="True">     184:</span>         <span class="f">}</span><span class="f">;</span>
<a name="185" /><span class="True">     185:</span>     <span class="f">}</span><span class="f">;</span>
<a name="186" /><span class="True">     186:</span> 
<a name="187" /><span class="True">     187:</span>     <span class="k">/* type specific data</span>
<a name="188" /><span class="True">     188:</span> <span class="k">     * - this is used by the keyring type to index the name</span>
<a name="189" /><span class="True">     189:</span> <span class="k">     */</span>
<a name="190" /><span class="True">     190:</span>     <span class="m">union</span> <span class="f">{</span>
<a name="191" /><span class="True">     191:</span>         <span class="m">struct</span> <span class="b">list_head</span>    <span class="b">link</span><span class="f">;</span>
<a name="192" /><span class="True">     192:</span>         <span class="m">unsigned</span> <span class="m">long</span>        <span class="b">x</span><span class="f">[</span><span class="c">2</span><span class="f">]</span><span class="f">;</span>
<a name="193" /><span class="True">     193:</span>         <span class="m">void</span>            <span class="f">*</span><span class="b">p</span><span class="f">[</span><span class="c">2</span><span class="f">]</span><span class="f">;</span>
<a name="194" /><span class="True">     194:</span>         <span class="m">int</span>            <span class="b">reject_error</span><span class="f">;</span>
<a name="195" /><span class="True">     195:</span>     <span class="f">}</span> <span class="b">type_data</span><span class="f">;</span>
<a name="196" /><span class="True">     196:</span> 
<a name="197" /><span class="True">     197:</span>     <span class="k">/* key data</span>
<a name="198" /><span class="True">     198:</span> <span class="k">     * - this is used to hold the data actually used in cryptography or</span>
<a name="199" /><span class="True">     199:</span> <span class="k">     *   whatever</span>
<a name="200" /><span class="True">     200:</span> <span class="k">     */</span>
<a name="201" /><span class="True">     201:</span>     <span class="m">union</span> <span class="f">{</span>
<a name="202" /><span class="True">     202:</span>         <span class="m">union</span> <span class="f">{</span>
<a name="203" /><span class="True">     203:</span>             <span class="m">unsigned</span> <span class="m">long</span>        <span class="b">value</span><span class="f">;</span>
<a name="204" /><span class="True">     204:</span>             <span class="m">void</span> <a href="cpu.c_macros_ref.html#_X19yY3VfMA__"><span class="b">__rcu</span></a>        <span class="f">*</span><span class="b">rcudata</span><span class="f">;</span>
<a name="205" /><span class="True">     205:</span>             <span class="m">void</span>            <span class="f">*</span><span class="b">data</span><span class="f">;</span>
<a name="206" /><span class="True">     206:</span>             <span class="m">void</span>            <span class="f">*</span><span class="b">data2</span><span class="f">[</span><span class="c">2</span><span class="f">]</span><span class="f">;</span>
<a name="207" /><span class="True">     207:</span>         <span class="f">}</span> <span class="b">payload</span><span class="f">;</span>
<a name="208" /><span class="True">     208:</span>         <span class="m">struct</span> <span class="b">assoc_array</span> <span class="b">keys</span><span class="f">;</span>
<a name="209" /><span class="True">     209:</span>     <span class="f">}</span><span class="f">;</span>
<a name="210" /><span class="True">     210:</span> <span class="f">}</span><span class="f">;</span>
<a name="211" /><span class="True">     211:</span> 
<a name="212" /><span class="True">     212:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key_alloc</span><span class="f">(</span><span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="213" /><span class="True">     213:</span>                  <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">desc</span><span class="f">,</span>
<a name="214" /><span class="True">     214:</span>                  <span class="b">kuid_t</span> <span class="b">uid</span><span class="f">,</span> <span class="b">kgid_t</span> <span class="b">gid</span><span class="f">,</span>
<a name="215" /><span class="True">     215:</span>                  <span class="m">const</span> <span class="m">struct</span> <span class="b">cred</span> <span class="f">*</span><span class="b">cred</span><span class="f">,</span>
<a name="216" /><span class="True">     216:</span>                  <span class="b">key_perm_t</span> <span class="b">perm</span><span class="f">,</span>
<a name="217" /><span class="True">     217:</span>                  <span class="m">unsigned</span> <span class="m">long</span> <span class="b">flags</span><span class="f">)</span><span class="f">;</span>
<a name="218" /><span class="True">     218:</span> 
<a name="219" /><span class="True">     219:</span> 
<a name="220" /><span class="True">     220:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0FMTE9DX0lOX1FVT1RBXzA_"><span class="b">KEY_ALLOC_IN_QUOTA</span></a>    <span class="c">0x0000</span>    <span class="k">/* add to quota, reject if would overrun */</span>
<a name="221" /><span class="True">     221:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0FMTE9DX1FVT1RBX09WRVJSVU5fMA__"><span class="b">KEY_ALLOC_QUOTA_OVERRUN</span></a>    <span class="c">0x0001</span>    <span class="k">/* add to quota, permit even if overrun */</span>
<a name="222" /><span class="True">     222:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0FMTE9DX05PVF9JTl9RVU9UQV8w"><span class="b">KEY_ALLOC_NOT_IN_QUOTA</span></a>    <span class="c">0x0002</span>    <span class="k">/* not in quota */</span>
<a name="223" /><span class="True">     223:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_S0VZX0FMTE9DX1RSVVNURURfMA__"><span class="b">KEY_ALLOC_TRUSTED</span></a>    <span class="c">0x0004</span>    <span class="k">/* Key should be flagged as trusted */</span>
<a name="224" /><span class="True">     224:</span> 
<a name="225" /><span class="True">     225:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_revoke</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="226" /><span class="True">     226:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_invalidate</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="227" /><span class="True">     227:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_put</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="228" /><span class="True">     228:</span> 
<a name="229" /><span class="True">     229:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">__key_get</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span>
<a name="230" /><span class="True">     230:</span> <span class="f">{</span>
<a name="231" /><span class="True">     231:</span>     <span class="b">atomic_inc</span><span class="f">(</span><span class="f">&amp;</span><span class="b">key</span><span class="f">-&gt;</span><span class="b">usage</span><span class="f">)</span><span class="f">;</span>
<a name="232" /><span class="True">     232:</span>     <span class="m">return</span> <span class="b">key</span><span class="f">;</span>
<a name="233" /><span class="True">     233:</span> <span class="f">}</span>
<a name="234" /><span class="True">     234:</span> 
<a name="235" /><span class="True">     235:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key_get</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span>
<a name="236" /><span class="True">     236:</span> <span class="f">{</span>
<a name="237" /><span class="True">     237:</span>     <span class="m">return</span> <span class="b">key</span> <span class="f">?</span> <span class="b">__key_get</span><span class="f">(</span><span class="b">key</span><span class="f">)</span> <span class="f">:</span> <span class="b">key</span><span class="f">;</span>
<a name="238" /><span class="True">     238:</span> <span class="f">}</span>
<a name="239" /><span class="True">     239:</span> 
<a name="240" /><span class="True">     240:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">void</span> <span class="b">key_ref_put</span><span class="f">(</span><span class="b">key_ref_t</span> <span class="b">key_ref</span><span class="f">)</span>
<a name="241" /><span class="True">     241:</span> <span class="f">{</span>
<a name="242" /><span class="True">     242:</span>     <span class="b">key_put</span><span class="f">(</span><span class="b">key_ref_to_ptr</span><span class="f">(</span><span class="b">key_ref</span><span class="f">)</span><span class="f">)</span><span class="f">;</span>
<a name="243" /><span class="True">     243:</span> <span class="f">}</span>
<a name="244" /><span class="True">     244:</span> 
<a name="245" /><span class="True">     245:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">request_key</span><span class="f">(</span><span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="246" /><span class="True">     246:</span>                    <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span>
<a name="247" /><span class="True">     247:</span>                    <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">callout_info</span><span class="f">)</span><span class="f">;</span>
<a name="248" /><span class="True">     248:</span> 
<a name="249" /><span class="True">     249:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">request_key_with_auxdata</span><span class="f">(</span><span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="250" /><span class="True">     250:</span>                         <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span>
<a name="251" /><span class="True">     251:</span>                         <span class="m">const</span> <span class="m">void</span> <span class="f">*</span><span class="b">callout_info</span><span class="f">,</span>
<a name="252" /><span class="True">     252:</span>                         <span class="b">size_t</span> <span class="b">callout_len</span><span class="f">,</span>
<a name="253" /><span class="True">     253:</span>                         <span class="m">void</span> <span class="f">*</span><span class="b">aux</span><span class="f">)</span><span class="f">;</span>
<a name="254" /><span class="True">     254:</span> 
<a name="255" /><span class="True">     255:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">request_key_async</span><span class="f">(</span><span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="256" /><span class="True">     256:</span>                      <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span>
<a name="257" /><span class="True">     257:</span>                      <span class="m">const</span> <span class="m">void</span> <span class="f">*</span><span class="b">callout_info</span><span class="f">,</span>
<a name="258" /><span class="True">     258:</span>                      <span class="b">size_t</span> <span class="b">callout_len</span><span class="f">)</span><span class="f">;</span>
<a name="259" /><span class="True">     259:</span> 
<a name="260" /><span class="True">     260:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">request_key_async_with_auxdata</span><span class="f">(</span><span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="261" /><span class="True">     261:</span>                           <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span>
<a name="262" /><span class="True">     262:</span>                           <span class="m">const</span> <span class="m">void</span> <span class="f">*</span><span class="b">callout_info</span><span class="f">,</span>
<a name="263" /><span class="True">     263:</span>                           <span class="b">size_t</span> <span class="b">callout_len</span><span class="f">,</span>
<a name="264" /><span class="True">     264:</span>                           <span class="m">void</span> <span class="f">*</span><span class="b">aux</span><span class="f">)</span><span class="f">;</span>
<a name="265" /><span class="True">     265:</span> 
<a name="266" /><span class="True">     266:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">wait_for_key_construction</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">,</span> <span class="m">bool</span> <span class="b">intr</span><span class="f">)</span><span class="f">;</span>
<a name="267" /><span class="True">     267:</span> 
<a name="268" /><span class="True">     268:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">key_validate</span><span class="f">(</span><span class="m">const</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="269" /><span class="True">     269:</span> 
<a name="270" /><span class="True">     270:</span> <span class="m">extern</span> <span class="b">key_ref_t</span> <span class="b">key_create_or_update</span><span class="f">(</span><span class="b">key_ref_t</span> <span class="b">keyring</span><span class="f">,</span>
<a name="271" /><span class="True">     271:</span>                       <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="272" /><span class="True">     272:</span>                       <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span>
<a name="273" /><span class="True">     273:</span>                       <span class="m">const</span> <span class="m">void</span> <span class="f">*</span><span class="b">payload</span><span class="f">,</span>
<a name="274" /><span class="True">     274:</span>                       <span class="b">size_t</span> <span class="b">plen</span><span class="f">,</span>
<a name="275" /><span class="True">     275:</span>                       <span class="b">key_perm_t</span> <span class="b">perm</span><span class="f">,</span>
<a name="276" /><span class="True">     276:</span>                       <span class="m">unsigned</span> <span class="m">long</span> <span class="b">flags</span><span class="f">)</span><span class="f">;</span>
<a name="277" /><span class="True">     277:</span> 
<a name="278" /><span class="True">     278:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">key_update</span><span class="f">(</span><span class="b">key_ref_t</span> <span class="b">key</span><span class="f">,</span>
<a name="279" /><span class="True">     279:</span>               <span class="m">const</span> <span class="m">void</span> <span class="f">*</span><span class="b">payload</span><span class="f">,</span>
<a name="280" /><span class="True">     280:</span>               <span class="b">size_t</span> <span class="b">plen</span><span class="f">)</span><span class="f">;</span>
<a name="281" /><span class="True">     281:</span> 
<a name="282" /><span class="True">     282:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">key_link</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">keyring</span><span class="f">,</span>
<a name="283" /><span class="True">     283:</span>             <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="284" /><span class="True">     284:</span> 
<a name="285" /><span class="True">     285:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">key_unlink</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">keyring</span><span class="f">,</span>
<a name="286" /><span class="True">     286:</span>               <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="287" /><span class="True">     287:</span> 
<a name="288" /><span class="True">     288:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">keyring_alloc</span><span class="f">(</span><span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">,</span> <span class="b">kuid_t</span> <span class="b">uid</span><span class="f">,</span> <span class="b">kgid_t</span> <span class="b">gid</span><span class="f">,</span>
<a name="289" /><span class="True">     289:</span>                  <span class="m">const</span> <span class="m">struct</span> <span class="b">cred</span> <span class="f">*</span><span class="b">cred</span><span class="f">,</span>
<a name="290" /><span class="True">     290:</span>                  <span class="b">key_perm_t</span> <span class="b">perm</span><span class="f">,</span>
<a name="291" /><span class="True">     291:</span>                  <span class="m">unsigned</span> <span class="m">long</span> <span class="b">flags</span><span class="f">,</span>
<a name="292" /><span class="True">     292:</span>                  <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">dest</span><span class="f">)</span><span class="f">;</span>
<a name="293" /><span class="True">     293:</span> 
<a name="294" /><span class="True">     294:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">keyring_clear</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">keyring</span><span class="f">)</span><span class="f">;</span>
<a name="295" /><span class="True">     295:</span> 
<a name="296" /><span class="True">     296:</span> <span class="m">extern</span> <span class="b">key_ref_t</span> <span class="b">keyring_search</span><span class="f">(</span><span class="b">key_ref_t</span> <span class="b">keyring</span><span class="f">,</span>
<a name="297" /><span class="True">     297:</span>                 <span class="m">struct</span> <span class="b">key_type</span> <span class="f">*</span><span class="b">type</span><span class="f">,</span>
<a name="298" /><span class="True">     298:</span>                 <span class="m">const</span> <span class="m">char</span> <span class="f">*</span><span class="b">description</span><span class="f">)</span><span class="f">;</span>
<a name="299" /><span class="True">     299:</span> 
<a name="300" /><span class="True">     300:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">keyring_add_key</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">keyring</span><span class="f">,</span>
<a name="301" /><span class="True">     301:</span>                <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span><span class="f">;</span>
<a name="302" /><span class="True">     302:</span> 
<a name="303" /><span class="True">     303:</span> <span class="m">extern</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key_lookup</span><span class="f">(</span><span class="b">key_serial_t</span> <span class="b">id</span><span class="f">)</span><span class="f">;</span>
<a name="304" /><span class="True">     304:</span> 
<a name="305" /><span class="True">     305:</span> <span class="m">static</span> <span class="m">inline</span> <span class="b">key_serial_t</span> <span class="b">key_serial</span><span class="f">(</span><span class="m">const</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span>
<a name="306" /><span class="True">     306:</span> <span class="f">{</span>
<a name="307" /><span class="True">     307:</span>     <span class="m">return</span> <span class="b">key</span> <span class="f">?</span> <span class="b">key</span><span class="f">-&gt;</span><span class="b">serial</span> <span class="f">:</span> <span class="c">0</span><span class="f">;</span>
<a name="308" /><span class="True">     308:</span> <span class="f">}</span>
<a name="309" /><span class="True">     309:</span> 
<a name="310" /><span class="True">     310:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_set_timeout</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="f">,</span> <span class="m">unsigned</span><span class="f">)</span><span class="f">;</span>
<a name="311" /><span class="True">     311:</span> 
<a name="312" /><span class="True">     312:</span> <span class="k">/**</span>
<a name="313" /><span class="True">     313:</span> <span class="k"> * key_is_instantiated - Determine if a key has been positively instantiated</span>
<a name="314" /><span class="True">     314:</span> <span class="k"> * @key: The key to check.</span>
<a name="315" /><span class="True">     315:</span> <span class="k"> *</span>
<a name="316" /><span class="True">     316:</span> <span class="k"> * Return true if the specified key has been positively instantiated, false</span>
<a name="317" /><span class="True">     317:</span> <span class="k"> * otherwise.</span>
<a name="318" /><span class="True">     318:</span> <span class="k"> */</span>
<a name="319" /><span class="True">     319:</span> <span class="m">static</span> <span class="m">inline</span> <span class="m">bool</span> <span class="b">key_is_instantiated</span><span class="f">(</span><span class="m">const</span> <span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="b">key</span><span class="f">)</span>
<a name="320" /><span class="True">     320:</span> <span class="f">{</span>
<a name="321" /><span class="True">     321:</span>     <span class="m">return</span> <a href="cpu.c_macros_ref.html#_dGVzdF9iaXRfMA__"><span class="b">test_bit</span></a><span class="f">(</span><a href="cpu.c_macros_ref.html#_S0VZX0ZMQUdfSU5TVEFOVElBVEVEXzA_"><span class="b">KEY_FLAG_INSTANTIATED</span></a><span class="f">,</span> <span class="f">&amp;</span><span class="b">key</span><span class="f">-&gt;</span><span class="b">flags</span><span class="f">)</span> <span class="f">&amp;&amp;</span>
<a name="322" /><span class="True">     322:</span>         <span class="f">!</span><a href="cpu.c_macros_ref.html#_dGVzdF9iaXRfMA__"><span class="b">test_bit</span></a><span class="f">(</span><a href="cpu.c_macros_ref.html#_S0VZX0ZMQUdfTkVHQVRJVkVfMA__"><span class="b">KEY_FLAG_NEGATIVE</span></a><span class="f">,</span> <span class="f">&amp;</span><span class="b">key</span><span class="f">-&gt;</span><span class="b">flags</span><span class="f">)</span><span class="f">;</span>
<a name="323" /><span class="True">     323:</span> <span class="f">}</span>
<a name="324" /><span class="True">     324:</span> 
<a name="325" /><span class="True">     325:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_cmN1X2RlcmVmZXJlbmNlX2tleV8w"><span class="b">rcu_dereference_key</span></a><span class="f">(</span><span class="b">KEY</span><span class="f">)</span>                    \
<a name="326" /><span class="True">     326:</span>     <span class="f">(</span><a href="cpu.c_macros_ref.html#_cmN1X2RlcmVmZXJlbmNlX3Byb3RlY3RlZF8w"><span class="b">rcu_dereference_protected</span></a><span class="f">(</span><span class="f">(</span><span class="b">KEY</span><span class="f">)</span><span class="f">-&gt;</span><span class="b">payload</span><span class="f">.</span><span class="b">rcudata</span><span class="f">,</span>        \
<a name="327" /><span class="True">     327:</span>                    <span class="b">rwsem_is_locked</span><span class="f">(</span><span class="f">&amp;</span><span class="f">(</span><span class="f">(</span><span class="m">struct</span> <span class="b">key</span> <span class="f">*</span><span class="f">)</span><span class="f">(</span><span class="b">KEY</span><span class="f">)</span><span class="f">)</span><span class="f">-&gt;</span><span class="b">sem</span><span class="f">)</span><span class="f">)</span><span class="f">)</span>
<a name="328" /><span class="True">     328:</span> 
<a name="329" /><span class="True">     329:</span> <span class="f">#</span><span class="n">define</span> <a href="cpu.c_macros_noref.html#_cmN1X2Fzc2lnbl9rZXlwb2ludGVyXzA_"><span class="b">rcu_assign_keypointer</span></a><span class="f">(</span><span class="b">KEY</span><span class="f">,</span> <span class="b">PAYLOAD</span><span class="f">)</span>                \
<a name="330" /><span class="True">     330:</span> <span class="m">do</span> <span class="f">{</span>                                    \
<a name="331" /><span class="True">     331:</span>     <a href="cpu.c_macros_ref.html#_cmN1X2Fzc2lnbl9wb2ludGVyXzA_"><span class="b">rcu_assign_pointer</span></a><span class="f">(</span><span class="f">(</span><span class="b">KEY</span><span class="f">)</span><span class="f">-&gt;</span><span class="b">payload</span><span class="f">.</span><span class="b">rcudata</span><span class="f">,</span> <span class="f">(</span><span class="b">PAYLOAD</span><span class="f">)</span><span class="f">)</span><span class="f">;</span>        \
<a name="332" /><span class="True">     332:</span> <span class="f">}</span> <span class="m">while</span> <span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="333" /><span class="True">     333:</span> 
<a name="334" /><span class="True">     334:</span> <span class="f">#</span><span class="n">ifdef</span> <a href="cpu.c_macros_ref.html#_Q09ORklHX1NZU0NUTF8w"><span class="b">CONFIG_SYSCTL</span></a>
<a name="335" /><span class="True">     335:</span> <span class="m">extern</span> <span class="b">ctl_table</span> <span class="b">key_sysctls</span><span class="f">[</span><span class="f">]</span><span class="f">;</span>
<a name="336" /><span class="True">     336:</span> <span class="f">#</span><span class="n">endif</span>
<a name="337" /><span class="True">     337:</span> <span class="k">/*</span>
<a name="338" /><span class="True">     338:</span> <span class="k"> * the userspace interface</span>
<a name="339" /><span class="True">     339:</span> <span class="k"> */</span>
<a name="340" /><span class="True">     340:</span> <span class="m">extern</span> <span class="m">int</span> <span class="b">install_thread_keyring_to_cred</span><span class="f">(</span><span class="m">struct</span> <span class="b">cred</span> <span class="f">*</span><span class="b">cred</span><span class="f">)</span><span class="f">;</span>
<a name="341" /><span class="True">     341:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_fsuid_changed</span><span class="f">(</span><span class="m">struct</span> <span class="b">task_struct</span> <span class="f">*</span><span class="b">tsk</span><span class="f">)</span><span class="f">;</span>
<a name="342" /><span class="True">     342:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_fsgid_changed</span><span class="f">(</span><span class="m">struct</span> <span class="b">task_struct</span> <span class="f">*</span><span class="b">tsk</span><span class="f">)</span><span class="f">;</span>
<a name="343" /><span class="True">     343:</span> <span class="m">extern</span> <span class="m">void</span> <span class="b">key_init</span><span class="f">(</span><span class="m">void</span><span class="f">)</span><span class="f">;</span>
<a name="344" /><span class="True">     344:</span> 
<a name="345" /><span class="False">     345:</span> <span class="f">#</span><span class="n">else</span> <span class="k">/* CONFIG_KEYS */</span>
<a name="346" /><span class="False">     346:</span> 
<a name="347" /><span class="False">     347:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_validate</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>            <span class="c">0</span>
<a name="348" /><span class="False">     348:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_serial</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>            <span class="c">0</span>
<a name="349" /><span class="False">     349:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_get</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>             <span class="f">(</span><span class="f">{</span> <a href="cpu.c_macros_ref.html#_TlVMTF8w"><span class="b">NULL</span></a><span class="f">;</span> <span class="f">}</span><span class="f">)</span>
<a name="350" /><span class="False">     350:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_revoke</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>            <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="351" /><span class="False">     351:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_invalidate</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>        <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="352" /><span class="False">     352:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_put</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>            <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="353" /><span class="False">     353:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_ref_put</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>            <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="354" /><span class="False">     354:</span> <span class="f">#</span><span class="n">define</span> <span class="b">make_key_ref</span><span class="f">(</span><span class="b">k</span><span class="f">,</span> <span class="b">p</span><span class="f">)</span>        <a href="cpu.c_macros_ref.html#_TlVMTF8w"><span class="b">NULL</span></a>
<a name="355" /><span class="False">     355:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_ref_to_ptr</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>        <a href="cpu.c_macros_ref.html#_TlVMTF8w"><span class="b">NULL</span></a>
<a name="356" /><span class="False">     356:</span> <span class="f">#</span><span class="n">define</span> <span class="b">is_key_possessed</span><span class="f">(</span><span class="b">k</span><span class="f">)</span>        <span class="c">0</span>
<a name="357" /><span class="False">     357:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_fsuid_changed</span><span class="f">(</span><span class="b">t</span><span class="f">)</span>        <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="358" /><span class="False">     358:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_fsgid_changed</span><span class="f">(</span><span class="b">t</span><span class="f">)</span>        <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="359" /><span class="False">     359:</span> <span class="f">#</span><span class="n">define</span> <span class="b">key_init</span><span class="f">(</span><span class="f">)</span>            <span class="m">do</span> <span class="f">{</span> <span class="f">}</span> <span class="m">while</span><span class="f">(</span><span class="c">0</span><span class="f">)</span>
<a name="360" /><span class="False">     360:</span> 
<a name="361" /><span class="True">     361:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* CONFIG_KEYS */</span>
<a name="362" /><span class="True">     362:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* __KERNEL__ */</span>
<a name="363" /><span class="True">     363:</span> <span class="f">#</span><span class="n">endif</span> <span class="k">/* _LINUX_KEY_H */</span>
<a name="364" /><span class="True">     364:</span> </pre>
  </body>
</html>
